class Button
{
  private int x;
  private int y;
  private int imageWidth;
  private int imageHeight;
  private PImage regular;
  private PImage over;
  private PImage pressed;
  private PImage current;
  private Menu menu;
  
  public Button(int x, int y, int imageWidth, int imageHeight, PImage regular, PImage over, PImage pressed, Menu menu)
  {
    this.x = x;
    this.y = y;
    this.imageWidth = imageWidth;
    this.imageHeight = imageHeight;
    this.regular = regular;
    this.over = over;
    this.pressed = pressed;
    this.current = regular;
    this.menu = menu;
  }
    
  public void draw()
  {
     update();
     image(current, x, y); 
  }
  
  private void update()
  {
    setImage();
  }
  
  private void setImage()
  {
    if (isPressed())
      current = pressed;
    else if (overButton())
      current = over;
    else
      current = regular;
  }
  
  private boolean overButton()
  {
    if (mouseX >= x && mouseX <= x+imageWidth && mouseY >= y && mouseY <= y+imageHeight) 
      return true;
    else 
      return false;
  }
  
  public boolean isPressed()
  {
    if (overButton() && mousePressed)
      return true;
    else
      return false;
  }
}
